package L01;
//线程状态

public class T11 {
    public static void main (String[] args) throws InterruptedException {
        Thread t=new Thread (()->{
            while(true){
                try {
                    //TIMED_WAITING,线程正在sleep中
                    Thread.sleep (1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException (e);
                }
            }
        });
        //在调用start()之前获取状态，是NEW状态
        //

        System.out.println (t.getState ());
        t.start ();

        for (int i = 0; i < 5; i++) {
            System.out.println (t.getState ());
            Thread.sleep (1000);
        }

        t.join ();
        //线程结束后，TERMINATED
        System.out.println (t.getState ());
    }

}
